<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%String path = request.getContextPath();%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>供应商公告消息表 管理</title>
    <style type="text/css">
    </style>
    <jsp:include page="../../import.jsp" flush="true"/>
</head>

<body class="iframeBody">
<div class="Wrapper">
    <div class="searchArea">
        <form id="searchBar">
            <div class="fieldset1 clearFix">
                <div class="fieldBox">
                    <div class="label">消息描述</div>
                    <div class="field">
                        <input name="descr" id="" type="text" class="ui-textbox" value="">
                    </div>
                </div>
                
                <div class="fieldBox">
                    <div class="label">标题</div>
                    <div class="field">
                        <input name="title" id="" type="text" class="ui-textbox" value="">
                    </div>
                </div>
                
                <div class="fieldBox">
                    <div class="label">摘要</div>
                    <div class="field">
                        <input name="abs" id="" type="text" class="ui-textbox" value="">
                    </div>
                </div>

                <div class="clearFix"></div>
                <div class="btnsBox">
                    <span id="searchBtn" class="sq-button sq-button-round">查询</span>
                    <span id="clearBtn" class="sq-button sq-button-round">清空</span>
                    <span id="addBtn" class="sq-button sq-button-round">新增</span>
                </div>
            </div>
        </form>
    </div>
    <div id="ligergrid1" class="sq-grid"></div>
</div>

<script type="text/javascript">
    var grid = null,callback=null;
    $(function () {
        grid = $("#ligergrid1").ligerGrid({
            url: '<%=path%>/splmsg/splBullMsgInfo/initList.do',
            method: 'get',
            columns: [
		{display: '消息ID', name: 'id', minWidth: 125, align: 'left', enabledSort: false},
		{display: '描述', name: 'descr', minWidth: 100, align: 'left', enabledSort: false},
        {display: '标题', name: 'title', minWidth: 100, align: 'left', enabledSort: false},
        {display: '摘要', name: 'abs', minWidth: 100, align: 'left', enabledSort: false},
        {display: '内容编号', name: 'cntId', minWidth: 100, align: 'left', enabledSort: false},
		//{display: '封面图片', name: 'cvrPicUrl', minWidth: 100, align: 'left', enabledSort: false},
		{display: '内容URL', name: 'cntUrl', minWidth: 100, align: 'left', enabledSort: false},
		{display: '编辑时间', name: 'mdfTm', minWidth: 100, align: 'left', render:renderDate, enabledSort:true},
		{display: '编辑人', name: 'mdfUsrNm', minWidth: 100, align: 'left', enabledSort: false},
		{
			display: '操作',width: 150,
			render: function (rowdata, rowindex, value){
				var h1 = '<a class="sq-button-hasicon" href="javascript:void(0);" onclick="modifySplBullMsg('+rowdata.id+')"><i class="sqBtnIco_4"></i>修改</a>'
				var h2 = '<a class="sq-button-hasicon" href="javascript:void(0);" onclick="delSplBullMsg('+rowdata.id+')"><i class="sqBtnIco_7"></i>删除</a>';
				return h1+h2;
			}
		}
            ],
            pageSize: 10,
            root: 'rows',
            record: 'total',
            hideLoadButton: true,
            width: '100%',
            height: '100%',
            heightDiff: -2,
            //isScroll: false,
            checkbox: false,
            rownumbers: true,
            allowUnSelectRow: true,
            alternatingRow: false
            /* onRenderComplete: function () {
             iframeResize ();
             } */
        });
        grid.setHeight(100);

        $("#searchBar").ligerForm();

        $("#pageloading").hide();

        /* 查询 */
        $("#searchBtn").click(function (event) {
            var form = liger.get("searchBar");
            var data = form.getData();
            for (name in data) {
                grid.setParm(name, data[name]);
            }
            grid.reload();
        });

        /* 清空 */
        $("#clearBtn").click(function (event) {
            clearLigerForm("searchBar");
        });
        
        callback = function () {
            grid.reload();
        };

        /* 新增 */
        $("#addBtn").click(function (event) {
            Add_navTab("SplBullMsgInfo_1", "新增公告消息", '<%=path%>/splmsg/splBullMsgInfo/toAddPage.do', callback);
        });
    });
    /* 修改 */
    function modifySplBullMsg(_id){
    	Add_navTab('SplBullMsgInfo_2'+_id, "修改公告消息", '<%=path%>/splmsg/splBullMsgInfo/toModifyPage.do?id='+_id, callback);
    }

    /* 删除 */
    function delSplBullMsg(id){
    	var _ids = [];
       	_ids.push(id);
		$.ligerDialog.confirm(LogUtils.LOG_CMM_DELETE_CONFIRM, function (flag) {
        if (flag == false)return;
        var wait_dialog;
                  $.ajax({
                      type: 'post',
                      dataType: 'json',
                      data: {ids: JSON.stringify(_ids)},
                      url: '<%=path%>/splmsg/splBullMsgInfo/removeByIds.do',
                      beforeSend: function () {
                          wait_dialog = $.ligerDialog.SQalert({
                              content: LogUtils.LOG_CMM_DATA_LOADING,
                              SQ_type: "waitting"
                          });
                      },
                      success: function (msg) {
                          wait_dialog.close();
                          if (msg.success == 1) {
                              $.ligerDialog.SQalert({content: msg.info, SQ_type: "success"});
                              grid.reload();
                          } else {
                              $.ligerDialog.SQalert({content: msg.info, SQ_type: "error"});
                          }
                      }
                  });
              });
        }
	//格式化时间
	function renderDate(rowdata, index, value){
		var dateStr = "";
		if(null != value){
			var date = new Date(value);
			dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DDHHMMSS);
		}
		return dateStr;
	}

</script>

</body>
</html>
